package com.jiuyou.clientController.mall.order;

import com.alibaba.fastjson.JSONObject;
import com.huifu.adapay.core.AdapayCore;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.core.util.AdapaySign;
import com.huifu.adapay.model.Payment;
import com.jiuyou.clientController.base.ClientBaseController;
import com.jiuyou.clientController.order.OrderClientController;
import com.ruoyi.adapayDiv.service.IAdapayDivService;
import com.ruoyi.adapayMember.domain.AdapayMember;
import com.ruoyi.adapayMember.service.IAdapayMemberService;
import com.ruoyi.adapayRecord.domain.AdapayRecord;
import com.ruoyi.adapayRecord.service.IAdapayRecordService;
import com.ruoyi.adapayRefund.domain.AdapayRefund;
import com.ruoyi.adapayRefund.service.IAdapayRefundService;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.Member;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.OrderNoUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.coupons.domain.CouponsMember;
import com.ruoyi.coupons.service.ICouponsMemberService;
import com.ruoyi.member.service.IMemberService;
import com.ruoyi.order.domain.StoreProductOrder;
import com.ruoyi.order.domain.StoreProductOrderHandle;
import com.ruoyi.order.service.IStoreProductOrderHandleService;
import com.ruoyi.shopping.domain.*;
import com.ruoyi.shopping.service.*;
import com.ruoyi.system.service.ISysConfigService;
import org.apache.commons.lang3.ObjectUtils;
import org.aspectj.bridge.IMessageHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.OrderUtils;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author chengliang
 * @date 2022/6/28
 **/
@RestController
@RequestMapping("/client/mall/order")
public class MallOrderClientController extends ClientBaseController {
    private static final Logger log = LoggerFactory.getLogger(MallOrderClientController.class);

    @Autowired
    private IMallOrderService orderService;
    @Autowired
    private IMallOrderMeshService meshService;
    @Autowired
    private IMallCouponsMemberService couponsService;
    @Autowired
    private IMallProductSpecsService specsService;
    @Autowired
    private IMallProductService productService;
    @Autowired
    private IStoreProductOrderHandleService handleService;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private IMemberService memberService;
    @Autowired
    private IMallShoppingCartService cartService;
    @Autowired
    private IAdapayRecordService adapayRecordService;
    @Autowired
    private IAdapayRefundService adapayRefundService;
//    @Autowired
//    private IMallIntegralService integralService;
//    @Autowired
//    private IMallIntegralRecordService integralRecordService;

    @Autowired
    private IMallAddressService addressService;

    @RequestMapping("/create")
    public AjaxResult create(@RequestBody NeedPayProductVo vo) throws Exception {
        //校验优惠券
        MallCouponsMember couponsMember = null;
        couponsMember = couponsService.selectMallCouponsMemberById(vo.getCouponId());
        List<MallCouponsMember> mallCouponsMembers = couponsService.canUseList(vo.getCartVos(), getLoginMemberId());
        if(mallCouponsMembers.size()>0){
            MallCouponsMember finalCouponsMember = couponsMember;
            boolean flag = mallCouponsMembers.stream().anyMatch(a -> finalCouponsMember.getCouponId().equals(a.getCouponId()));
            if(!flag){
                return AjaxResult.success("优惠券无法使用");
            }
        }
        if(couponsMember == null){
            couponsMember = new MallCouponsMember();
            couponsMember.setMoney(new BigDecimal("1"));
            couponsMember.setPrimaryKey("");
        }

        BigDecimal couponMoney = couponsMember.getMoney();
        String couponType = couponsMember.getCouponType();
        List<Long> collect = new ArrayList<>();
        if(!"general".equals(couponType)){
            String[] primaryKey = StringUtils.deleteArrayNull(couponsMember.getPrimaryKey().split(","));
            collect = Arrays.stream(primaryKey)
                    .map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
        }
        List<CartVo> cartVos = vo.getCartVos();
        BigDecimal price = BigDecimal.ZERO;
        ArrayList<MallOrder> orders = new ArrayList<>();
        Date date = new Date();
        String s = DateUtils.parseDateToStr("yyMMdd", date);
        MallOrderMesh mesh = genMallOrderMesh(s);
        MallAddress mallAddress = addressService.selectMallAddressById(vo.getAddrId());
        String  append = new StringBuilder(mallAddress.getProvinceName()).append(" ").append(mallAddress.getCityName()).append(" ").append(mallAddress.getAreaName())
                .append(" ").append(mallAddress.getStreetName()).append(" ").append(mallAddress.getAddressName()).toString();
        for (CartVo cartVo : cartVos) {
            MallProductSpecs specs = specsService.selectMallProductSpecsById(cartVo.getSpecsId());
            MallProduct product = productService.selectMallProductById(specs.getProductId());
            product.setSalesNum(product.getSalesNum()+cartVo.getCountNum());
            BigDecimal multiply = specs.getCurrentPrice().multiply(new BigDecimal(cartVo.getCountNum()));
            cartVo.setCountPrice(multiply);
            price = price.add(multiply);
            MallOrder order = new MallOrder();
            if("product".equals(couponType)){
                if(collect.contains(product.getId())){
                    order.setCouponId(couponsMember.getCouponId());
                }
            }else if("classify".equals(couponType)){
                if(collect.contains(product.getClassifyId())){
                    order.setCouponId(couponsMember.getCouponId());
                }
            }else if("general".equals(couponType)) {
                order.setCouponId(couponsMember.getCouponId());
            }
            order.setConsigneeName(mallAddress.getRecipientName());
            order.setConsigneePhone(mallAddress.getPhone());
            order.setConsigneeAddress(append);
            order.setCreateTime(date);
            order.setProductName(product.getProductName());
            order.setProductImage(product.getProductImage());
            order.setMergeOrderId(mesh.getId());
            order.setOrderId(genOrderId(s));
            order.setProductBackId(product.getProductBackId());
            order.setProductId(product.getId());
            order.setSpecsBackId(specs.getSpecsBackId());
            order.setCouponId(couponsMember.getCouponId());
            order.setOrderState(DicConstants.ORDER_STATE_Wait_Ship.getCode());

            order.setSpecificationName(specs.getSpecsName());
            order.setSpecificationId(specs.getId());
            order.setMemberId(getLoginMemberId());
            order.setPayPrice(multiply);
            order.setNum(cartVo.getCountNum());
            specs.setSalesNum(specs.getSalesNum()+cartVo.getCountNum());
            specsService.updateMallProductSpecs(specs);
            productService.updateMallProduct(product);
            orders.add(order);
        }

        mesh.setCustomerRemark(vo.getCustomerRemark());
        mesh.setName(orders.get(0).getProductName());
        Iterator<MallOrder> iterator = orders.iterator();
        ArrayList<MallOrder> mallOrders = new ArrayList<>();
        while(iterator.hasNext()){
            MallOrder item = iterator.next();
            if(item.getCouponId() != null){
                mallOrders.add(item);
                iterator.remove();
            }
        }
        //根据应付金额排序
        mallOrders.sort(Comparator.comparing(MallOrder::getPayPrice));
        //订单金额总数
        BigDecimal sum = mallOrders.stream().map(MallOrder::getPayPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
        //处理优惠券金额大于商品金额情况
        handleSpecialOrder(couponsMember,sum);
//        BigDecimal divide = couponsMember.getMoney().divide(orders.size()-1, 2, BigDecimal.ROUND_HALF_UP);
        ArrayList<MallOrder> needInsr = new ArrayList<>();
        if(mallOrders.size()>0){
            List<MallOrder> mallOrders1 = mallOrders.subList(0, mallOrders.size() - 1);
            BigDecimal last = couponMoney;
            for (int i = 0; i < mallOrders1.size(); i++) {
                MallOrder mallOrder = mallOrders1.get(i);
//                        单笔订单金额/使用红包的订单金额总数 * 红包金额
                BigDecimal divide = mallOrder.getPayPrice().divide(sum, 2, BigDecimal.ROUND_HALF_UP).multiply(couponMoney);
                last = last.subtract(divide);
                BigDecimal subtract = mallOrder.getPayPrice().subtract(divide);
                if(subtract.compareTo(BigDecimal.ZERO)<=0){
                    mallOrder.setPayPrice(BigDecimal.ZERO);
                }else{
                    mallOrder.setPayPrice(subtract);
                }
                mallOrder.setDeductionPrice(divide);
            }
            MallOrder mallOrder = mallOrders.get(mallOrders.size() - 1);
            mallOrder.setPayPrice(mallOrder.getPayPrice().subtract(last));
            mallOrder.setDeductionPrice(last);
            if(couponsMember.getId() == null){
                mallOrder.setDeductionPrice(BigDecimal.ZERO);
            }
            mallOrders1.add(mallOrder);
            needInsr.addAll(mallOrders1);
        }
//        else{
//            for (MallOrder mallOrder:orders){
//                if(mallOrder.getPayPrice().compareTo(BigDecimal.ZERO)<=0){
//                    mallOrder.setPayPrice(new BigDecimal("0.01"));
//                }
//                mallOrder.setDeductionPrice(couponMoney);
//                if(couponsMember.getId() == null){
//                    mallOrder.setDeductionPrice(BigDecimal.ZERO);
//                }
//            }
//        }
        if(orders.size()>1){
            mesh.setName(orders.get(0).getProductName()+"等");
        }
        couponsMember.setUseState(DicConstants.SYS_Y.getCode());
        couponsMember.setCanUseState(DicConstants.SYS_N.getCode());
        couponsService.updateMallCouponsMember(couponsMember);
        needInsr.addAll(orders);
        calcTotalPrice(mesh,needInsr);
        orderService.insrAll(needInsr);
        handleOrderOperation(mesh,needInsr);
        handleCart(vo.getRoute(),cartVos);
        meshService.updateMallOrderMesh(mesh);
//        doSuccess(mesh.getId(),"虚假的订单编号");
        return AjaxResult.success(mesh);
    }

    private void handleSpecialOrder(MallCouponsMember couponsMember, BigDecimal sum) {
        if(couponsMember.getMoney().compareTo(sum)>-1){
            couponsMember.getMoney().add(new BigDecimal("0.01"));
        }
    }

    private void calcTotalPrice(MallOrderMesh mesh,List<MallOrder> orders) {
        BigDecimal total = BigDecimal.ZERO;
        for (MallOrder order : orders) {
            if(order.getPayPrice().compareTo(BigDecimal.ZERO)  < 1){
                order.setPayPrice(BigDecimal.ZERO);
            }
            total = total.add(order.getPayPrice());
        }
        mesh.setPayPrice(total);
        mesh.setPayState(DicConstants.SYS_N.getCode());
    }
    private void handleCart(String route, List<CartVo> cartVos) {
        List<Long> collect = cartVos.stream().map(CartVo::getSpecsId).collect(Collectors.toList());
        if("shoppingCar".equals(route)){
            cartService.deleteBySpecsIds(collect,getLoginMemberId());
        }
    }


    private void handleOrderOperation(MallOrderMesh mesh, ArrayList<MallOrder> needInsr) {
        ArrayList<StoreProductOrderHandle> list = new ArrayList<>();
        Date date = new Date();
        needInsr.forEach(e->{
            StoreProductOrderHandle handle = new StoreProductOrderHandle();
            handle.setHandleUserId(mesh.getMemberId());
            handle.setHandleDetail(e.toString());
            handle.setMeshId(mesh.getId());
            handle.setOrderId(e.getId());
            handle.setHandleName("商城订单创建");
            handle.setHandleUserName(getUsername());
            handle.setHandleOrderType(DicConstants.ORDER_MALL.getCode());
            handle.setCreateTime(date);
            list.add(handle);
        });
        handleService.insrAll(list);
    }

    private String genOrderId(String dateStr) {
        String verifyCode = OrderNoUtil.getNum(8);
        verifyCode = dateStr+verifyCode;
        MallOrder exist = orderService.selectByOrderId(verifyCode);
        if(exist != null){
            genOrderId(dateStr);
        }
        return verifyCode;

    }

    private MallOrderMesh genMallOrderMesh(String dateStr) {
        MallOrderMesh mallOrderMesh = new MallOrderMesh();
        String verifyCode = OrderNoUtil.getNum(8);
        verifyCode = dateStr+verifyCode;
//        OrderNoUtil.getOrderNo(getLoginMemberId())
        MallOrderMesh exist = meshService.selectByOrderId(verifyCode);
        if(exist != null){
            genMallOrderMesh(dateStr);
        }else{
            mallOrderMesh.setOrderState(DicConstants.ORDER_STATE_Wait_Pay.getCode());
            mallOrderMesh.setOrderId(verifyCode);
            mallOrderMesh.setMemberId(getLoginMemberId());
            meshService.insertMallOrderMesh(mallOrderMesh);
        }
        return mallOrderMesh;
    }

    @PostMapping("/delayPay")
    public AjaxResult delayPay( Long orderId)  {

        MallOrderMesh mesh = meshService.selectMallOrderMeshById(orderId);

        if (null == mesh) {
            return AjaxResult.error("未找到该订单");
        }
        Long loginMemberId= getLoginMemberId();
        if(null==loginMemberId){
            return AjaxResult.error("刷新后再试");
        }
        Member member= memberService.selectMemberById(loginMemberId);
        if(member.getId().compareTo(mesh.getMemberId())!=0){
            return AjaxResult.error("警告：请勿支付他人订单");
        }
        if(!DicConstants.SYS_N.getCode().equals( mesh.getPayState())){
            return AjaxResult.error("该订单无需支付");
        }
        if(!DicConstants.ORDER_STATE_Wait_Pay.getCode().equals(mesh.getOrderState())){
            return AjaxResult.error("该订单已取消");
        }
        //调用sdk方法，创建支付，得到支付对象
        Map<String, Object> payment = new HashMap<>();
        System.out.println("=======execute payment begin=======");
        //创建支付对象的参数，全部参数请参考 https://docs.adapay.tech/api/index.html
        Map<String, Object> paymentParams = new HashMap<>(10);
        String app_id=configService.selectConfigByKey("adpay_app_id");
        paymentParams.put("app_id", app_id);
        String order_no="wx" + System.currentTimeMillis();
        paymentParams.put("order_no", order_no);
        paymentParams.put("pay_channel", "wx_lite");
        BigDecimal payPrice=mesh.getPayPrice();
        if(payPrice.compareTo(new BigDecimal("0"))==0){
            return AjaxResult.error("0元订单无法支付");
        }
        String pay_amt=mesh.getPayPrice().toString();
        paymentParams.put("pay_amt", pay_amt);

        paymentParams.put("goods_title", mesh.getName());
        paymentParams.put("goods_desc", mesh.getName());

        paymentParams.put("div_members", "");
        paymentParams.put("pay_mode", "delay");
        Map<String, Object> expendParams = new HashMap<>(2);
        String openId = member.getOpenId();//微信授权获取
        expendParams.put("open_id", openId);
        paymentParams.put("expend", expendParams);
        String domain=configService.selectConfigByKey("domain");
        String notify_url=/*request.getScheme()+*/domain+"/prod-api/client/mall/order/notify";
        paymentParams.put("notify_url", notify_url);

        AdapayRecord adapayRecord=new AdapayRecord();
        adapayRecord.setPayOrderId(order_no);
        adapayRecord.setReqState(DicConstants.SYS_Y.getCode());
        adapayRecord.setProductOrderId(orderId);
        adapayRecord.setReqParam(paymentParams.toString());
        adapayRecord.setCreateBy(member.getId());
        adapayRecord.setBelongType("mall");

        try {
            payment = Payment.create(paymentParams);
        }catch (Exception e){
            adapayRecord.setReqState((DicConstants.SYS_N.getCode()));
            adapayRecord.setReqFailMsg(e.getMessage());
            adapayRecordService.insertAdapayRecord(adapayRecord);
            return AjaxResult.error(e.getMessage());
        }
        adapayRecord.setResParam(payment.toString());
        String error_code = (String) payment.get("error_code");
        if (null != error_code) {
            String error_msg = (String) payment.get("error_msg");
            System.out.println("error_code:" + error_code + "............." + error_msg);
            adapayRecord.setReqState((DicConstants.SYS_N.getCode()));
            adapayRecord.setReqFailMsg(error_msg);
            adapayRecordService.insertAdapayRecord(adapayRecord);
            return AjaxResult.error(error_msg);
        }
        adapayRecord.setPaymentId( (String)payment.get("id"));
        adapayRecordService.insertAdapayRecord(adapayRecord);
        return  AjaxResult.success(payment);
    }
    /**
     * 支付付款回调
     * @param request
     */
    @RequestMapping("/notify")
    public void notify(HttpServletRequest request) {
        try {
            //验签请参data
            String data = request.getParameter("data");
            //验签请参sign
            String sign = request.getParameter("sign");
            //验签标记
            boolean checkSign;
            //验签请参publicKey
            String publicKey = AdapayCore.PUBLIC_KEY;
            log.info("验签请参：data={}sign={}");
            //验签
            checkSign = AdapaySign.verifySign(data, sign, publicKey);
            if(checkSign){
                //验签成功逻辑
                System.out.println("成功返回数据data:"+data);
                JSONObject dataJson= JSONObject.parseObject(data);
                // pending 交易处理中 succeeded 交易成功 failed失败

                String order_no=dataJson.getString("order_no");//交易订单号？wx开头加时间戳
                AdapayRecord adapayRecordQuery=new AdapayRecord();
                adapayRecordQuery.setPayOrderId(order_no);
                List<AdapayRecord>  list=adapayRecordService.selectAdapayRecordList(adapayRecordQuery);
                if(list.size()>0) {
                    AdapayRecord adapayRecord=list.get(0);
                    String payState=adapayRecord.getPayState();

                    if("succeeded".equals(payState)){
                        //已经处理过
                        return;
                    }
                    String status=dataJson.getString("status");
                    String error_msg=dataJson.getString("error_msg");
                    AdapayRecord adapayRecordUpdate=new AdapayRecord();
                    adapayRecordUpdate.setId(adapayRecord.getId());
                    adapayRecordUpdate.setNotifyParam(data);
                    adapayRecordUpdate.setPayState(status);
                    if("succeeded".equals(status)){
                        //交易成功
                        //传递合并订单ID
                        doSuccess(  adapayRecord.getProductOrderId(),order_no);

                    }
                    if("failed".equals(status)){
                        //交易失败
                        adapayRecordUpdate.setPayFailMsg(error_msg);

                    }
                    adapayRecordUpdate.setUpdateTime(new Date());
                    adapayRecordService.updateAdapayRecord(adapayRecordUpdate);
                }

            }else {
                //验签失败逻辑
            }
        }catch (Exception e){
            log.info("异步回调开始，参数，request={}");
        }
        return ;
    }

    private void doSuccess(Long orderId,String orderNo) throws Exception {
        MallOrderMesh meshOrder = meshService.selectMallOrderMeshById(orderId);
//        Long memberId = getLoginMemberId();
        meshOrder.setPayTime(new Date());
        meshOrder.setPayOrderNo(orderNo);
        meshOrder.setPayState(DicConstants.SYS_Y.getCode());
        //支付成功后将状态置为待使用
        List<MallOrder> mallOrders = orderService.selectMallOrderByMeshId(meshOrder.getId());
        mallOrders.forEach(e->{
            e.setOrderState(DicConstants.ORDER_STATE_Wait_Ship.getCode());
            orderService.updateMallOrder(e);
        });
        meshOrder.setOrderState(DicConstants.ORDER_STATE_Wait_Ship.getCode());
        meshOrder.setShipState(DicConstants.ORDER_STATE_Wait_Ship.getCode());
        meshService.updateMallOrderMesh(meshOrder);
        StoreProductOrderHandle orderHandle = new StoreProductOrderHandle();
        orderHandle.setCreateType(DicConstants.BUSINESS_Customer.getCode());
        orderHandle.setMeshId(meshOrder.getId());
        orderHandle.setCreateBy(0L);
        List<Long> collect = mallOrders.stream().map(MallOrder::getId).collect(Collectors.toList());
//        orderHandle.setOrderId(collect);
        orderHandle.setHandleName("支付回调");
        orderHandle.setHandleDetail(meshOrder.toString());
        handleService.insertStoreProductOrderHandle(orderHandle);
//        handleWithDraw(meshOrder);
    }

    private void handleWithDraw(MallOrderMesh mesh) {

    }

    @RequestMapping("/confirm")
    public AjaxResult confirm(@RequestBody List<CartVo> cartVos){
//        List<Long> productIds = cartVos.stream().map(CartVo::getProductId).collect(Collectors.toList());
        List<Long> specsIds = cartVos.stream().map(CartVo::getSpecsId).collect(Collectors.toList());
//        List<MallProduct> products = productService.selectMallProductByIds(productIds);
        List<MallProductSpecs> specsList = specsService.selectListByIds(specsIds);
        ArrayList<Map<Long, JSONObject>> maps = new ArrayList<>();
        ArrayList<Long> lapseIds = new ArrayList<>();
        specsList.forEach(e->{
            HashMap<Long, JSONObject> map = new HashMap<>();
            MallProduct product = productService.selectMallProductById(e.getProductId());
            JSONObject jso = new JSONObject();
            jso.put("productName",product.getProductName());
            String mainImg = e.getSpecsPhoto();
            if(StringUtils.isEmpty(mainImg)){
                mainImg = product.getProductImage();
            }
            jso.put("mainImg",mainImg);
            jso.put("specsName",e.getSpecsName());
            jso.put("price",e.getCurrentPrice());
            jso.put("specsId",e.getId());
            jso.put("productId",product.getId());
            map.put(product.getId(),jso);
            for (CartVo vo:cartVos ) {
                if(vo.getSpecsId().equals(e.getId())){
                    jso.put("count",vo.getCountNum());
                    break;
                }
            }
            maps.add(map);
        });
        return AjaxResult.success(maps);
    }

    /**
     * 退款支付回调
     * @param request
     */
    @RequestMapping("/refundPayNotify")
    public void refundPayNotify(HttpServletRequest request) {
        try {
            //验签请参data
            String data = request.getParameter("data");
            //验签请参sign
            String sign = request.getParameter("sign");
            //验签标记
            boolean checkSign;
            //验签请参publicKey
            String publicKey = AdapayCore.PUBLIC_KEY;
            log.info("验签请参：data={}sign={}");
            //验签
            checkSign = AdapaySign.verifySign(data, sign, publicKey);
            if(checkSign){
                //验签成功逻辑
                System.out.println("refundPayNotify成功返回数据退款回调data:"+data);
                JSONObject dataJson= JSONObject.parseObject(data);
                String order_no=dataJson.getString("order_no");//交易订单号？
                AdapayRefund adapayRefundQuery=new AdapayRefund();
                adapayRefundQuery.setRefundOrderNo(order_no);
                List<AdapayRefund> listre=   adapayRefundService.selectAdapayRefundList(adapayRefundQuery);
                if(listre.size()>0){
                    AdapayRefund adapayRefund=listre.get(0);
                    String refundState=  adapayRefund.getRefundState();
                    if("succeeded".equals(refundState)){
                        //已经处理过
                        return;
                    }

                    AdapayRefund adapayRefundUpdate=new AdapayRefund();
                    adapayRefundUpdate.setId(adapayRefund.getId());
                    String status=dataJson.getString("status");
                    adapayRefundUpdate.setRefundState(status);
                    Long productOrderId=  adapayRefund.getProductOrderId();
                    MallOrder order=new MallOrder();
                    order.setId(productOrderId);
                    if("succeeded".equals(status)){
                        //退款成功
                        order.setRefundPayStatus(DicConstants.SYS_Y.getCode());
                    }
                    if("failed".equals(status)){
                        //交易失败
                        order.setRefundPayStatus(DicConstants.SYS_N.getCode());
                    }
                    orderService.updateMallOrder(order);
                    adapayRefundUpdate.setUpdateTime(new Date());
                    adapayRefundUpdate.setNotifyParam(data);
                    adapayRefundService.updateAdapayRefund(adapayRefundUpdate);
                }

            }else {
                //验签失败逻辑
            }
        }catch (Exception e){
            log.info("异步回调开始，参数，request={}");
        }
        return ;
    }

}
